<template>
	<view>
		<u-navbar back-icon-color="#fff" :is-back="false" title-color="#fff" title="考试分析" :border-bottom="false"></u-navbar>
		<view class="group">
			<my-empty v-if="emptyFlase" emptyTit="您还没有发布考试，快去创建吧~"></my-empty>
			<my-an-item v-else  @click.native="gotoLink(paper.examid)"
			:key="paper.examid"
			v-for="paper in dataList.list"
			:itemName="paper.examname"
			>
			<view slot="botLeft"><my-icon name="time"></my-icon><text class="botTxt">结束时间：{{paper.endtime}}</text></view>
			<view slot="botRight"><my-icon name="baifenbi"></my-icon><text class="botTxt">及格率：{{paper.passProportion}}</text></view>
			</my-an-item>
		</view>
		<!-- <u-loadmore v-show="isShowLoadMore" bg-color="#f5f5f5" @loadmore="getDataList()" :status="status" icon-type="flower" :load-text="loadText" /> -->
	</view>
</template>

<script>
	export default{
		data() {
			return {
				status: 'loadmore',
				dataList: {
					list: [],
					pageNo: 1,
					isLastPage: false
				},
				loadText: {
					loadmore: '点击更多',
					loading: '加载中...',
					nomore: '没有更多了'
				},
				emptyFlase:false
			}
		},
		onLoad() {
			this.init();
		},
		onReachBottom(){
				if (!this.dataList.isLastPage) this.getDataList();
		},
		methods: {
			// 默认
			init() {
				this.status = 'loadmore';
				this.dataList = {
					list: [],
					pageNo: 1,
					isLastPage: false
				};
				return this.getDataList();
			},
			// 跳转链接
			gotoLink(examid){
				uni.navigateTo({
					url:'./examDetails?examid='+examid
				})
			},
			// 获取列表
		  getDataList(){
				 const { pageNo } = this.dataList;
				 this.status = 'loading';
				 const pageData={
					 'pageNo':pageNo
				 }
				 return new Promise((resolve, reject) => {
				 	this.request
				 		.post('/app/teacher/examanalysis/getExamAnalysisList',pageData)
				 		.then(res => {
							const { list, isLastPage } = res;
				 			this.dataList.list = this.dataList.list.concat(list);
							this.emptyFlase=this.dataList.list.length>0?false:true
				 			this.dataList.isLastPage = isLastPage;
				 			if (!isLastPage) this.dataList.pageNo++;
				 			else this.status = 'nomore';
				 			resolve();
				 		})
				 		.catch(reject);
				 });
			 }
		}
	}
</script>

<style lang="scss" scoped>
  .botTxt{margin-left:0upx;}
</style>
